//delete_group.sqf
#include "ACV_Constantes.h"
#include "ACV_ID_main_dlg.h"
private ["_display","_list","_btn_delete","_index","_varname","_grp","_arr","_txt_sys","_i","_lb","_nb","_msg"];
disableSerialization;
_display = findDisplay ACV_DLG_ID_Main_Dlg;
_list = _display displayCtrl ACV_DLG_ID_Main_LstStock;
_btn_delete = _display displayCtrl ACV_DLG_ID_Main_BtnDeleteUnit;
_txt_sys = _display displayCtrl ACV_DLG_ID_Main_TxtSystem;
_index = lbCurSel ACV_DLG_ID_Main_LstStock;
_lb = lbSelection _list;
_nb = count _lb;
call ACV_FNCT_ClearAll_WpMarkers;
if (_nb > 0) then {
	for [{ _i = _nb - 1}, { _i >= 0}, { _i = _i - 1}] do {
		_varname = lbData [ACV_DLG_ID_Main_LstStock,(_lb select _i)];
		_grp = false;
		call compile format ["_grp = %1",_varname];
		_arr = [];
		_arr set [ACV_NET_PARAM_OWNER,name player];
		_arr set [ACV_NET_PARAM_CLASS,_grp];
		_arr set [ACV_NET_PARAM_DISPLAYNAME,(_list lbText (_lb select _i))];
		ACV_NET_DeleteUnit = _arr;
		if (!IS_Server) then {
			publicVariable "ACV_NET_DeleteUnit";
		} else {
			[ACV_NET_DeleteUnit] call ACV_FNCT_DeleteUnit;
		};
		sleep 0.03; // OBLIGATOIRE
	};
	ACV_MARKER_LOC_Unit setMarkerPosLocal [0,0,0];
	call ACV_FNCT_ClearAll_WpMarkers;
	if (_nb == 1) then {
		_msg = format[localize "STR_MSG_DELETEGROUP",_arr select ACV_NET_PARAM_DISPLAYNAME,name player];
	} else {
		_msg = format[localize "STR_MSG_DELETEGROUPS",_nb,name player];
	};
	[_msg] call ACV_FNCT_BroadcastMessage;
};
_btn_delete ctrlEnable false;
